{\rtf1\mac\ansicpg10000\cocoartf102
{\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;\f1\fnil\fcharset77 Monaco;\f2\fswiss\fcharset77 Helvetica;
}
{\colortbl;\red255\green255\blue255;\red0\green0\blue0;\red0\green115\blue0;\red96\green96\blue96;
\red0\green0\blue191;}
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\f0\b\fs36 \cf0 TGrains2		buffer granulator with linear att/dec\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\f1\b0\fs18 \cf0 \
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\f2\fs24 \cf0 Triggers generate grains from a buffer. Each grain has a linear and is panned between two channels of multiple outputs.\
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\f0\b \cf0 TGrains2.ar(numChannels, trigger, bufnum, rate, centerPos, dur, pan, amp, att, dec, interp)\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\f2\b0 \cf0 \
	
\f0\b numChannels
\f2\b0  - number of output channels.\
	
\f0\b trigger
\f2\b0  - at each trigger, the following arguments are sampled and used \
		as the arguments of a new grain. \
		A trigger occurs when a signal changes from <= 0 to > 0.\
		If the trigger is audio rate then the grains will start with sample accuracy.\
	
\f0\b bufnum
\f2\b0  - the index of the buffer to use. It must be a one channel (mono) buffer.\
	
\f0\b rate
\f2\b0    -  1.0 is normal, 2.0 is one octave up, 0.5 is one octave down\
			-1.0 is backwards normal rate ... etc.\
		Unlike PlayBuf, the rate is multiplied by BufRate, so you needn't do that yourself.\
	
\f0\b centerPos
\f2\b0  - the position in the buffer in seconds at which the grain envelope will reach \
			maximum amplitude.\
	
\f0\b dur
\f2\b0     -   duration of the grain in seconds.\
	
\f0\b pan
\f2\b0     -   a value from -1 to 1. Determines where to pan the output in the same manner as PanAz.\
	
\f0\b amp
\f2\b0    - amplitude of the grain.\
	
\f0\b att 
\f2\b0 - attack time of grain in seconds.\
	
\f0\b dec 
\f2\b0 - decay time of grain in seconds.\
	
\f0\b interp
\f2\b0  - 1,2,or 4. Determines whether the grain uses (1) no interpolation, (2) linear interpolation, \
			or (4) cubic interpolation.\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\f1\fs18 \cf0 \
\
\cf2 s.sendMsg(\cf3 \\b_allocRead\cf2 , 10, \cf4 "sounds/a11wlk01.wav"\cf2 );\
\
(\
\{\
	\cf5 var\cf2  b = 10, trate, dur, clk;\
	trate = \cf5 MouseY\cf2 .kr(2,200,1);\
	dur = 4 / trate;\
	clk = \cf5 Dust\cf2 .kr(trate);\
	\cf5 TGrains2\cf2 .ar(2, clk, 10, 1.0, \cf5 LFNoise2\cf2 .kr(0.5).range(0, \cf5 BufDur\cf2 .kr(b)), dur, 0, \cf5 TRand\cf2 .kr(0.1, 0.2, clk), \cf5 MouseX\cf2 .kr(0.003, 0.01), 0.007, 4);\
\}.play;\
)\
\
(\
\{\
	\cf5 var\cf2  b = 10, trate, dur, clk, pos, pan;\
	trate = \cf5 MouseY\cf2 .kr(8,120,1);\
	dur = 12 / trate;\
	clk = \cf5 Impulse\cf2 .kr(trate);\
	pos = \cf5 MouseX\cf2 .kr(0,\cf5 BufDur\cf2 .kr(b)) + \cf5 TRand\cf2 .kr(0, 0.01, clk);\
	pan = \cf5 WhiteNoise\cf2 .kr(0.6);\
	\cf5 TGrains2\cf2 .ar(2, clk, b, 1, pos, dur, pan, 0.1, dur * 0.3, dur * 0.5);\
\}.play;\
)}